/*
 * Hidden Equity LLC
 * Author: Maksym Fedyay, Kyiv, mcsimf@gmail.com
 * Date: 29.02.2012
 */

package com.hiddenequity.tips;

import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import com.hiddenequity.utils.XMLUtils;

public class TipResponseParser {

	
	Document _XMLDocument;


	/*
	 * Constructor
	 */
	public TipResponseParser(String XMLData){

		try {
			_XMLDocument = XMLUtils.XMLStringToDoc(XMLData);
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}//Constructor
	
	
	/*
	 * Get tip from service
	 */
	public String getTip(){

		String result = null;
		
		try {
			NodeList GetTipsResult = _XMLDocument.getElementsByTagName("string");
			result =  XMLUtils.getCharacterDataFromElement((Element) GetTipsResult.item(0));
	    } catch (Exception e) {
	    	e.printStackTrace();
	    }

		return result;
	}
	
	
}
